<%@page import="com.honeycomb.user.dto.UserLoginInfo"%>
<%@page import="com.honeycomb.utils.SystemConstants"%>
<%@page import="com.honeycomb.user.dto.UserinfoDto"%>
<%@page import="com.honeycomb.common.PositionInfo"%>
<%@page import="java.util.Stack"%>
<%@page import="com.honeycomb.utils.SystemTools"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">   
<meta http-equiv="Expires" content="0">
<meta http-equiv="kiben" content="no-cache">
<title>修改个人资料</title>   
<link rel="stylesheet" href="<%=request.getContextPath() %>/resource/css/common.css" />
<link rel="stylesheet" href="<%=request.getContextPath() %>/resource/css/jquery.Jcrop.css" />
<link rel="stylesheet" href="<%=request.getContextPath() %>/resource/css/modityTip.css" />
<link rel="stylesheet" href="<%=request.getContextPath() %>/resource/css/jquery-ui.css" />
<link rel="stylesheet" href="<%=request.getContextPath() %>/resource/css/loading.css" />
<script type="text/javascript" src="<%=request.getContextPath() %>/resource/js/common.js"></script>    
<!-- script type="text/javascript" src="http://api.amap.com/webapi/init?v=1.1&key=8e224a5f1ea5161ede7d4d8da4f1cca0"></script -->
<script type="text/javascript" src="<%=request.getContextPath() %>/resource/js/jquery/jquery-1.8.2.js"></script>    
<script type="text/javascript" src="<%=request.getContextPath() %>/resource/js/jquery/jquery-ui.js"></script>     
<script type="text/javascript" src="<%=request.getContextPath() %>/resource/js/jquery/jquery.form.js"></script> 
<script type="text/javascript" src="<%=request.getContextPath() %>/resource/js/mydatepicker.js"></script>    
<script type="text/javascript" src="<%=request.getContextPath() %>/resource/js/jquery/jquery.ui.datepicker-zh-CN.js"></script>
<script type="text/javascript" src="<%=request.getContextPath() %>/resource/js/msgConstants.js"></script>
<script type="text/javascript" src="<%=request.getContextPath() %>/resource/js/honeycombtool.js"></script>
<script type="text/javascript" src="<%=request.getContextPath() %>/resource/js/modify.js"></script>
<script src="<%=request.getContextPath() %>/resource/js/jquery/jquery.Jcrop.js"></script>
</head>
<script type="text/javascript">
$(document).ready(function() {
	var dateInput = $('#userRegistBirthday');
	loadDatepicker(dateInput);
	// initMapContainer();
});

/*
function initMapContainer() {
	// 创建地图实例  
    var mapObj = new AMap.Map("container", {
    	level: 14, //地图初始化时的视野级别
    	zooms : [3,19], //地图视野级别范围，如：[3,19]，3 为最小级别，19 为最大级别
    	dragEnable : true, //定义地图是否可以拖拽
    	zoomEnable : true, //定义地图视野级别是否可以更改
    	keyboardEnable : true, //定义地图是否可以被键盘控制
    	jogEnable: true, //定义地图拖拽时是否支持缓动效果
    	continuousZoomEnable: true, //定义地图是否有连续缩放效果
    	doubleClickZoom : true, //定义地图是否可以双击放大
    	scrollWheel: true //定义地图是否支持鼠标滚轮缩放
    });
	// 加载工具条  
    mapObj.plugin(["AMap.ToolBar","AMap.OverView,AMap.Scale"], function() {  
		tool = new AMap.ToolBar({
			direction: false, // 隐藏方向导航
			ruler: false, // 隐藏视野级别控制尺
			autoPosition: false, // 禁止自动定位
			offset: {x: -10, y: 3}
		});
		mapObj.addControl(tool);
//			加载比例尺
		scale = new AMap.Scale();
		mapObj.addControl(scale); 
	});

	var marker = new AMap.Marker({  
		id:"myLocation",  
		position:e.lnglat,  
	    icon:"http://api.amap.com/webapi/static/Images/marker_sprite.png",
		offset:{x:-8,y:-34}  
	});  
	mapObj.addOverlays(marker);  
	
	mapObj.bind(mapObj,"click",function(e){  
		var marker = new AMap.Marker({  
			id:"myLocation",  
			position:e.lnglat,  
		    icon:"http://api.amap.com/webapi/static/Images/marker_sprite.png",
			offset:{x:-8,y:-34}  
		});  
		mapObj.addOverlays(marker);  

		var lnglatXY = e.lnglat;
		var geo = new AMap.Geocoder({ 
			range:100,//范围 
			crossnum:1,//道路交叉口数 
			roadnum :1,//路线记录数 
			poinum:1//POI点数 
		}); 
		geo.regeocode(lnglatXY,function(data){  
	        var resultStr="";  
	        if(data.status =="E0") {  
	            for(var i=0;i<data.list.length;i++){
	                resultStr += data.list[i].province.name+data.list[i].city.name+data.list[i].district.name; 
                    for(var j=0;j<data.list[i].roadlist.length;j++){  
                        resultStr+= data.list[i].roadlist[j].name;  
                    }  
	            }  
	        } else if(data.status =="E1") {  
	             resultStr = "未查找到任何结果!";     
	        } else {  
	             resultStr= "错误信息："+data.state;  
	        }  
	        $('#map_addr').val(resultStr);
	    });         
        $('#map_x').val(lnglatXY.lng);
        $('#map_y').val(lnglatXY.lat);
	});
}
*/

function filesubmit() {
	loadingWaiting('yuantu','cropbox','0');
          $('#myform').ajaxSubmit({
              dataType:  'json',
              url : '<%=getServletContext().getInitParameter("uploaderURL")%>',
              type: 'POST',
              success:function(res){
      			if(res.error == 0) {
    				callback(res.url);
    			}
    			else {
    				alert("系统保存文件错误！错误信息：" + res.message);
    				loadingWaiting('','','2');
    			}
              }
          });
	  
}

function callback(fullImgSrc)
{
	$("#yuantu").html("<img id=cropbox style='max-width:400px ;max-height:300px'>");
	$("#preview_box").html("<img id=crop_preview>");
	document.getElementById('cropbox').src = fullImgSrc;
	document.getElementById('crop_preview').src = fullImgSrc;
	$("#imgPath").val(fullImgSrc);
	loadingWaiting('yuantu','cropbox','01');
	$(function(){
		$('#cropbox').Jcrop({
			onChange:showPreview,
			onSelect:showPreview,
			aspectRatio:1,
			setSelect:[0,0,100,100]
		});
		
		function showPreview(coords){
			if(parseInt(coords.w) > 0){
				//计算预览区域图片缩放的比例，通过计算显示区域的宽度(与高度)与剪裁的宽度(与高度)之比得到
				var imgw=$("#crop_preview").width();
				var rx = $("#preview_box").width() / coords.w; 
				var ry = $("#preview_box").height() / coords.h;
				
				//通过比例值控制图片的样式与显示
				$("#crop_preview").css({
					width:Math.round(rx * $("#cropbox").width()) + "px",	//预览图片宽度为计算比例值与原图片宽度的乘积
					height:Math.round(rx * $("#cropbox").height()) + "px",	//预览图片高度为计算比例值与原图片高度的乘积
					marginLeft:"-" + Math.round(rx * coords.x) + "px",
					marginTop:"-" + Math.round(ry * coords.y) + "px"
				});

				$('#x').val(coords.x);
				$('#y').val(coords.y);
				$('#w').val(coords.w );
				$('#h').val(coords.h );
			}
		}
	});
}
function UploadZuoBiao(){
		var yuanW=$("#cropbox").width();//图片的宽
		var yuanH=$("#cropbox").height();//图片的高
		var x = $("#x").val();
		var y = $("#y").val();
		var w = $("#w").val();
		var h = $("#h").val();
		var imgPath = $("#imgPath").val();
		$.ajax({
			url: '<%=getServletContext().getInitParameter("saveToLogoURL")%>',
			data:{
				'x':x,
				'y':y,
				'w':w,
				'h':h,
				'yuanW':yuanW,
				'yuanH':yuanH,
				'imgPath':imgPath
				},
			type: 'post',
			async: false,
			dataType: 'json',
			success: function(res) {
					if(res.result == 0){
						$('#headUrl').html("<img src="+res.url+" style='width:80px ;height:80px'>");
						$("#imgPath").val(res.url);
						$('#outer').css("display","none");
					}
					else{
						alert("系统处理异常！错误信息：" + res.message);
						loadingWaiting('','','2');
					}
				}
	});
	 }	
	function pressModify(){
			$('#outer').css("display","block");
		}
</script>
<%
	UserinfoDto userInfoDto = (UserinfoDto)session.getAttribute(SystemConstants.LOGINUSER_SESSION_NAME);

	/** Stack<PositionInfo> positions = (Stack<PositionInfo>) session.getAttribute(SystemConstants.LOGINUSER_SESSION_FAVOUR_POSITIONS);
	PositionInfo defaultPosition = null;
	if (positions != null) {
		for (PositionInfo elem : positions) {
			if (elem.getType().equals(PositionInfo.PositionType.DEFAULT))
			{
				defaultPosition = elem;
			}
		}
		if (defaultPosition == null) {
			defaultPosition = positions.peek();	
		}
	}
	*/
	
	UserLoginInfo loginInfoDto =(UserLoginInfo) session.getAttribute(SystemConstants.LOGINUSER_SESSION_LOGIN_INFO);
%>

<%@ include file="top.jsp" %>
<body style="background: url('../resource/images/pages/top-foot/bg.jpg') repeat-x ;">
<div class='msgbox_layer_wrap'><span id='mode_tips_v2' style='z-index: 10000;' class='msgbox_layer'>
	<span class='gtl_ico_clear'></span><span id="tip"></span><span class='gtl_end'></span></span></div>
<div style="margin: 0 auto;width: 750px;height: 46px;line-height: 45px;text-align: left;font-size:18px;background:white;margin-top:72px;">
		<div style="margin-top:2px;margin-left:6px;width: 750px;height: 42px;border-bottom:1px solid #E8E8E8;">	
		<b>修改个人注册资料  </b>
		</div>
		</div>
	<div style="width: 970px;height: auto;overflow: hidden;margin: 0 auto;background:white;">
		<div style="margin-top:10px;margin-left: 150px;width: 970px;height: auto;overflow: hidden;">
			<div style="width: 500px;height: 50px;float:left;margin-left:15px;">
				<div class="focus" id="jiben" onclick="doOptions('1')">基本信息</div>
				<div  class="normal" id="password" onclick="doOptions('2')">修改密码</div>
				<!--  div class="normal" id="addres" onclick="doOptions('3')">注册地址</div -->
				<div style="float:left:width:150px;height:30px;border-bottom:1px solid gray;"></div>
				<div style="clear:both"></div>
			</div>
			<div style="width:600px;height: 510px;margin-left:3px;">
			
			<div id="1">
			<div style="width: 100%;height: 42px;line-height: 42px;text-align: left;margin-left:13px;">
				<div style="float: left;width: 290px;height: 100%;">
				 显示昵称：<input id="userRegistNickname" maxlength="10" name="userModifyNickname" onblur="checkUserModifyNickname()" type="text" value="<%= userInfoDto.getUserNickname()%>" style="height:25px;width:200px;">
				</div>
				<div id="userRegistNicknameError" style="float: left;width: 300px;height: 100%;font-size: 13px;">
					
				</div>
			</div>
			<div style="width: 100%;height: 42px;line-height: 42px;text-align: left;margin-left:13px;">
			<div style="float: left;width: 290px;height: 100%;">
				您的生日：<input readonly="readonly" id="userRegistBirthday" maxlength="10" style="height:25px;" name="userModifyBirthday" onchange="checkUserModifyBirthday()" value="<%=userInfoDto.getUserBirthday().formatDTString() %>" type="text" />
			</div>
			<div id="userReRegistBirthdayError" style="float: left;width: 240px;height: 100%;font-size: 13px;">
					
			</div>
		</div>
		<div style="width: 100%;height: 42px;line-height: 42px;text-align: left;margin-left:13px;">
			<div style="float: left;width: 290px;height: 100%;">
				个性签名：<input onblur="checkStatement()" id="statement" type="text" style="height:25px;" value="<%=userInfoDto.getStatement() %>"/>(至多30个字)
				
			</div>
			<div style="float: left;width: 240px;height: 100%;font-size: 13px;">
					
			</div>
		</div>
		<div style="width: 100%;line-height: 42px;text-align: left;margin-left:13px;">
			<div style="float: left;width:320px;heigh:350px;">
				头像上传：<a onclick="pressModify()">修改头像</a>&nbsp;&nbsp;&nbsp;&nbsp;(*&nbsp;上传头像在重新登录后生效)
							<div id="headUrl" style="margin-left:60px;">
							<img src="<%=userInfoDto.getUserHeadImagUrl() %>" width="80px;" height="80px;">
							</div>
					<div id="outer" style="left:40%;top:12%;width:650px;height: 500px;position: absolute;z-index: 100;opacity:0.99;display:none;background:white;border:2px solid gray;">
						<div id="preview" style="margin-left:10px;margin-top:20px;">
						<form action="<%=getServletContext().getInitParameter("uploaderURL")%>"" method="post" id="myform" name="myform" enctype="multipart/form-data" target="douplaod">
						<input type="file" name="file" id="filess"  onchange="filesubmit()">
					</form>
					<iframe name="douplaod" style="display:none">
					</iframe>
						<input type="hidden" id="x" name="x" value="0"/>
						<input type="hidden" id="y" name="y" value="0"/>
						<input type="hidden" id="w" name="w" value="100"/>
						<input type="hidden" id="h" name="h" value="100"/>
						<input type="hidden" id="imgPath" name="imgPath" value="<%=userInfoDto.getUserHeadImagUrl() %>">
						
						<div id="img_look">
								<div class="yuantu" id="yuantu"></div>
								<span id="preview_box" class="crop_preview"></span>
						</div>
						</div>
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="button" class="button_style" value="确定" onclick="UploadZuoBiao()"/>&nbsp;&nbsp;&nbsp;&nbsp;
				<input type="button" onclick="ToUserInfoModifiy()" class="button_style" value="取消">
					</div>
				</div>
			</div>
			
			<div style="margin-top:20px;padding-left:75px;float: left;width: 100%;height: 42px;line-height: 42px;text-align: left;">
				<input type="button" id="doUpdate01"  onClick="DoUpdate01()" class="button_style" value="保存修改">&nbsp;&nbsp;&nbsp;&nbsp;
				<input type="button" onclick="ToMain()" class="button_style" value="退出修改">
			</div>
			</div>
			<div id="2" style="display:none;margin-top:50px;">
				<div style="width: 100%;height: 42px;line-height: 42px;text-align: left;margin-left:13px;">
				<div style="float: left;width: 290px;height: 100%;">
					用户邮箱：<b><%=loginInfoDto.getLoginId() %></b>
				</div>
				</div>
				<div style="width: 100%;height: 42px;line-height: 42px;text-align: left;margin-left:13px;">
				<div style="float: left;width: 290px;height: 100%;">
							
					旧的密码：<input id="userOldPassword" maxlength="10" type="password" style="height:25px;width:200px;" onblur="userModifyPassword()">
				
				</div>
				<div id="userPassword" style="float: left;width: 280px;height: 100%;font-size: 13px;">
					
				</div>
			</div>
				<div style="width: 100%;height: 42px;line-height: 42px;text-align: left;margin-left:13px;">
				<div style="float: left;width: 290px;height: 100%;">
					新的密码：<input id="userRegistPassword" maxlength="10" name="userNewPassword" onblur="checkUserModifyPassword()" type="password" style="height:25px;width:200px;">
				</div>
				<div id="userRegistPasswordError" style="float: left;width: 280px;height: 100%;font-size: 13px;">
					
				</div>
			</div>
			<div style="width: 100%;height: 42px;line-height: 42px;text-align: left;margin-left:13px;">
				<div style="float: left;width: 290px;height: 100%;">
					确认密码：<input id="userReRegistPassword" maxlength="10" name="userReRegistPassword" onblur="checkUserReModifyPassword()" type="password" style="height:25px;width:200px;">
				</div>
				<div id="userReRegistPasswordError" style="float: left;width: 280px;height: 100%;font-size: 13px;">
					
				</div>
			</div>
			<div style="padding-left:75px;float: left;width: 100%;height: 42px;line-height: 42px;text-align: left;margin-left:13px;margin-top:10px;">
				<input type="button" onclick="DoUpdate02()" class="button_style" value="保存修改">&nbsp;&nbsp;&nbsp;&nbsp;
				<input type="button" onclick="ToMain()" class="button_style" value="退出修改">
			</div>
			</div>
			<!-- div id="3" style="display:none;margin-top:60px;margin-left:10px;">
				<div style="width: 100%;height: 300px;" onmouseout="checkModifyMapAddres()">
					<div style="float: left;width: 80px;height: 100%;">
						默认位置：<br><br>
						(登录系统时，个人图标将出现在你设置的默认位置上)
					</div>
					<div id="container" style="float: left;margin-left: 10px;width: 300px;height: 300px;border: 1px solid #CCCCCC;">
						
					</div>
					<div id="userModifyMapError" style="float: left;width: 80px;height: 100%;font-size: 13px;">
						
					</div>
				   <div style="width: 100%;height: auto;display:none;">
				    	经度：<input type="text" name="mapX" id="map_x" value="<%-- = defaultPosition == null ? 0.0 : defaultPosition.getLongitude() --%>"/><br />
				    	纬度：<input type="text" name="mapY" id="map_y" value="<%-- = defaultPosition == null ? 0.0 : defaultPosition.getLatitude() --%>"/><br />
				    	街道：<input type="text" name="mapAddr" id="map_addr" size="30" value="<%-- =  defaultPosition == null ? "" : defaultPosition.getAddress() --%>"/><br /> 
				    	地图提供商：<input type="text" name="mapProviderIdProperty" id="map_provider" value="<%-- = getServletContext().getInitParameter("map_amap_id") --%>"/><br /> 
	   				</div>
				</div>
				<div style="padding-left:75px;float: left;width: 100%;height: 42px;line-height: 42px;text-align: left;margin-left:13px;margin-top:15px;">
					<input type="button" onclick="DoUpdate03()" class="button_style" value="保存修改">&nbsp;&nbsp;&nbsp;&nbsp;
					<input type="button" onclick="ToMain()" class="button_style" value="退出修改">
				</div>
			</div -->
		</div>
		
			</div>
			
	</div>
	
<%@ include file="foot.jsp" %>

</body>
</html>